/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ventasInternet.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author DESARO03
 */
@Entity
@Table(name = "imagen")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Imagen.findAll", query = "SELECT i FROM Imagen i"),
    @NamedQuery(name = "Imagen.findByIdimage", query = "SELECT i FROM Imagen i WHERE i.idimage = :idimage"),
    @NamedQuery(name = "Imagen.findByRuta", query = "SELECT i FROM Imagen i WHERE i.ruta = :ruta"),
    @NamedQuery(name = "Imagen.findByProducto", query = "SELECT i FROM Imagen i WHERE i.productoidProd = :producto"),
    @NamedQuery(name = "Imagen.findByNombre", query = "SELECT i FROM Imagen i WHERE i.nombre = :nombre")})
public class Imagen implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
//    @Basic(optional = false)
//    @NotNull
    @Column(name = "idimage")
    private Integer idimage;
    @Size(max = 300)
    @Column(name = "ruta")
    private String ruta;
    @Size(max = 100)
    @Column(name = "nombre")
    private String nombre;
    @JoinColumn(name = "producto_idProd", referencedColumnName = "idProd")
    @ManyToOne(optional = false)
    private Producto productoidProd;

    public Imagen() {
    }

    public Imagen(Integer idimage) {
        this.idimage = idimage;
    }

    public Integer getIdimage() {
        return idimage;
    }

    public void setIdimage(Integer idimage) {
        this.idimage = idimage;
    }

    public String getRuta() {
        return ruta;
    }

    public void setRuta(String ruta) {
        this.ruta = ruta;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public Producto getProductoidProd() {
        return productoidProd;
    }

    public void setProductoidProd(Producto productoidProd) {
        this.productoidProd = productoidProd;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idimage != null ? idimage.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Imagen)) {
            return false;
        }
        Imagen other = (Imagen) object;
        if ((this.idimage == null && other.idimage != null) || (this.idimage != null && !this.idimage.equals(other.idimage))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ventasInternet.entity.Imagen[ idimage=" + idimage + " ]";
    }
    
}
